from appium import webdriver

import time

from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.webdriver import WebDriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

desired_caps = dict()

# 设置中文可输入
desired_caps['unicodeKeyboard'] = True
desired_caps['resetKeyboard'] = True
# 配置 appium
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = '111'
# 滑动解锁页面
desired_caps['appPackage'] = 'com.android.launcher3'
desired_caps['appActivity'] = '.Launcher'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

# 全局等待5s
driver.implicitly_wait(5)

# 1》获取手机屏幕大小
size = driver.get_window_size()  # {'width': 600, 'height': 1024}
# 2》向上滑动解锁，x轴不变，y轴越来越小
driver.swipe(size['width'] * 0.5, size['height'] * 0.9, size['width'] * 0.5, size['height'] * 0.1)

time.sleep(3)

driver.quit()
